﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace sp2google.common
{
    public static class Utils
    {
        public static void XmlSerialize(string path, object obj)
        {
            using(var stream = File.Open(path, FileMode.Create))
            {
                var serializer = new XmlSerializer(obj.GetType());
                serializer.Serialize(stream, obj);
            }
        }

        public static object XmlDeserialize(string path, Type type)
        {
            using(var stream = File.Open(path, FileMode.Open))
            {
                var serializer = new XmlSerializer(type);
                return serializer.Deserialize(stream);
            }
        }
    }
}
